"""
   Main source file for the headless UI. It's nice and simple and does
   almost nothing!
"""
import sys
import thread
from network import EntangledNetworkLayer
from listen import Listener
from ui_abstract import AbstractUI

class HeadlessUI(AbstractUI):
   #Unlike the TextUI, we don't have any interactivity, so we set up
   #as much as we can in the init and just let it run.
   def __init__(self, myPort, ip, port, shareDirs):
      if ip == "" or port == -1:
         print "Warning: Node is not connected to anything! You cannot fix this from here!"
      AbstractUI.__init__(self, myPort, ip, port, shareDirs)

   def __publishAllInDirs(self, directories, network):
      AbstractUI.__publishAllInDirs__(self, directories, network)

   def run(self, network):
      if len(self.shareDirs) > 0:
         self.__publishAllInDirs(self.shareDirs, network)
      #Main run loop
      try:
         while(1):
            continue
      except (KeyboardInterrupt, SystemExit):
         print
         return

   #We're headless, we don't care about this crap
   def searchResult(self, result):
      return
   def filePublished(self, result):
      return

